import { defineConfig } from 'vite'
import { fileURLToPath, URL } from 'node:url'
import autoImport from 'unplugin-auto-import/vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    vueDevTools(),
    autoImport({
      imports: ['vue', 'vue-router', 'pinia'],
      dts: false,
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    host: true,
    port: 9941,
    https: {
      key: 'cert/server.key',
      cert: 'cert/server.crt',
      ca: 'cert/ca.crt'
    },
    proxy: {
      '/socket.io': {
        target: 'ws://10.10.18.50:9940',
        changeOrigin: true,
        ws: true,
      },
    }
  },
})
